package com.py.androidUtils.UI.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.py.androidUtils.base.BaseCommAdapter;
import com.py.androidUtils.utils.LoadingImages;
import com.readyidu.app.R;

public class ArticleDetailsAdapter extends BaseCommAdapter<Object> {
	private LayoutInflater inflater;
	private Context mContext;

	public ArticleDetailsAdapter(Context context) {
		inflater = LayoutInflater.from(context);
		this.mContext = context;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if (convertView == null) {
			holder = new ViewHolder();
			convertView = inflater.inflate(R.layout.common_article_details_item, null);
			holder.userImg = (ImageView) convertView.findViewById(R.id.userImg);
			holder.name = (TextView) convertView.findViewById(R.id.name);
			holder.content = (TextView) convertView.findViewById(R.id.content);
			holder.line_message = (LinearLayout) convertView.findViewById(R.id.line_message);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		LoadingImages.getInstance().loadingImages("http://pic.baomihua.com/photos/201110/m_6_634546490868593750_15193389.jpg", holder.userImg, mContext.getResources().getDimensionPixelSize(R.dimen.size_40));
		holder.name.setText("等待" + position);
		holder.content.setText("阿斯达斯蒂芬森的防守对方发的地方的 的的的的的我发饿饿饿我完成是的是我  的发饿d 饿发发发发发的的的是是是");
		holder.line_message.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				articleDetailsClik.comments("等待" + position);
			}
		});
		holder.userImg.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				articleDetailsClik.chckUser(new Object());
			}
		});
		return convertView;
	}

	private final class ViewHolder {
		private ImageView userImg;
		private TextView name;
		private TextView content;
		private LinearLayout line_message;
	}

	public interface ArticleDetailsClik {
		void chckUser(Object object);

		void comments(String name);

	}

	public ArticleDetailsClik articleDetailsClik;

	public void setArticleDetailsClik(ArticleDetailsClik articleDetailsClik) {
		this.articleDetailsClik = articleDetailsClik;
	}
}
